package com.dandandog.framework.faces.el;

import javax.el.ELContext;
import javax.el.ELResolver;
import java.beans.FeatureDescriptor;
import java.util.Iterator;


/**
 * @Author: JohnnyLiu
 * @Date: 2021/10/9 10:49
 */
public class EmptyToNullStringELResolver extends ELResolver {

    @Override
    public Class<?> getCommonPropertyType(ELContext context, Object base) {
        return String.class;
    }


//    public <T> T convertToType(ELContext context, Object value, Class<?> targetType) {
//        if (value == null && targetType == String.class) {
//            context.setPropertyResolved(true);
//        }
//        return (T)value;
//    }

    @Override
    public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext elContext, Object o) {
        return null;
    }

    @Override
    public Class<?> getType(ELContext context, Object base, Object property) {
        return null;
    }

    @Override
    public Object getValue(ELContext context, Object base, Object property) {
        return null;
    }

    @Override
    public boolean isReadOnly(ELContext context, Object base, Object property) {
        return true;
    }



    @Override
    public void setValue(ELContext context, Object base, Object property, Object value) {
        // NOOP.
    }
}
